<template>
  <el-drawer v-model="addDrawer" size="48%" :show-close="false" @opened="openDrawer" @close="closeDrawer">
    <template #title>
      <h2><svg-icon icon-class="list"></svg-icon><span style="padding-left: 15px">{{ typeName }}</span></h2>
      <el-button type="primary" @click="confirmClick" :disabled="drawerLoading" v-if="isShowSave">保存</el-button>
    </template>
    <template #default>
      <el-form :model="form" ref="addRef" :inline="true" :rules="formRules" label-width="160px" v-loading="drawerLoading">
        <el-row justify="space-between">
          <el-form-item label="省">
            <el-input v-model="form.province" clearable disabled></el-input>
          </el-form-item>
          <el-form-item label="市">
            <el-input v-model="form.city" clearable disabled></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="区/县">
            <el-input v-model="form.county" clearable disabled></el-input>
          </el-form-item>
          <el-form-item label="钻孔编号" prop="id">
            <el-input v-model="form.id" placeholder="请输入钻孔编号" clearable maxlength="17"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="钻探日期" prop="drillDate">
            <el-input v-model="form.drillDate" placeholder="请输入钻探日期" clearable maxlength="8" />
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="钻探地点" prop="locationName" style="width: 100%">
            <el-input v-model="form.locationName" placeholder="请输入钻探地点" clearable :autosize="{ minRows: 2, maxRows: 4 }"
              type="textarea" show-word-limit maxlength="40" resize="none"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="孔位经度" prop="lon">
            <el-input v-model="form.lon" placeholder="请输入孔位经度" clearable maxlength="8"></el-input>
          </el-form-item>
          <el-form-item label="孔位纬度" prop="lat">
            <el-input v-model="form.lat" placeholder="请输入孔位纬度" clearable maxlength="8"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="孔口标高 [米]" prop="elevation">
            <el-input v-model="form.elevation" placeholder="请输入孔口标高 [米]" clearable maxlength="8"></el-input>
          </el-form-item>
          <el-form-item label="孔深" prop="depth">
            <el-input v-model="form.depth" placeholder="请输入孔深" clearable maxlength="8"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="岩芯总长 [米]" prop="coreTotalThickness">
            <el-input v-model="form.coreTotalThickness" placeholder="请输入岩芯总长 [米]" clearable maxlength="8"></el-input>
          </el-form-item>
          <el-form-item label="全新统厚度 [米]" prop="holoceneThickness">
            <el-input v-model="form.holoceneThickness" placeholder="请输入全新统厚度 [米]" clearable maxlength="8"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="上更新统厚度 [米]" prop="upPleiThickness">
            <el-input v-model="form.upPleiThickness" placeholder="请输入上更新统厚度 [米]" clearable maxlength="8"></el-input>
          </el-form-item>
          <el-form-item label="中更新统厚度 [米]" prop="midPleiThickness">
            <el-input v-model="form.midPleiThickness" placeholder="请输入中更新统厚度 [米]" clearable maxlength="8"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="下更新统厚度 [米]" prop="lowPleiThickness">
            <el-input v-model="form.lowPleiThickness" placeholder="请输入下更新统厚度 [米]" clearable maxlength="8"></el-input>
          </el-form-item>
          <el-form-item label="前第四纪厚度 [米]" prop="prePleiThickness">
            <el-input v-model="form.prePleiThickness" placeholder="请输入前第四纪厚度 [米]" clearable maxlength="8"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="是否开展地球物理测井" prop="isGeophyWell">
            <dict-select code="TrueOrFalse" :value="form.isGeophyWell" @update="updateDict('isGeophyWell', $event)"></dict-select>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="钻孔柱状图图像文件编号" prop="columnChartAiid" style="width:100%">
            <el-space direction="vertical" alignment="flex-start" :size="15" class="upload-space">
              <el-input v-model="form.columnChartAiid" placeholder="请输入钻孔柱状图图像文件编号" clearable
                maxlength="20"></el-input>
              <ImageUpload v-model="form.columnChartAiidName"
                @uploadImage="uploadSuccess('columnChartAiid', $event)" @delFile="deleteFile('columnChartAiid', $event)" />
            </el-space>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="钻孔柱状图原始档案编号" prop="columnChartArwid" style="width:100%">
            <el-space direction="vertical" alignment="flex-start" :size="15" class="upload-space">
              <el-input v-model="form.columnChartArwid" placeholder="请输入钻孔柱状图原始档案编号" clearable
                maxlength="20"></el-input>
              <FileUpload v-model="form.columnChartArwidName"
                @uploadFile="uploadSuccess('columnChartArwid', $event)" @delFile="deleteFile('columnChartArwid', $event)" />
            </el-space>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="钻孔描述" prop="commentInfo" style="width:100%">
            <el-input v-model="form.commentInfo" placeholder="请输入钻孔描述" :autosize="{ minRows: 6, maxRows: 12 }"
              type="textarea" show-word-limit maxlength="2147483647" clearable></el-input>
          </el-form-item>
        </el-row>
      </el-form>
    </template>
  </el-drawer>
</template>
<script setup>
import useSpatialData from '@/hooks/useSpatialData'
import { eightDouble } from '@/utils/validate'
const { route, addDrawer, drawerLoading, form, typeName, openDrawer, closeDrawer, confirmClick, uploadSuccess, deleteFile, updateDict, isShowSave } = useSpatialData()
const formRules = {
  id: [{ required: true, message: '请填写钻孔编号！', trigger: 'blur' }],
  lon: [eightDouble],
  lat: [eightDouble],
  elevation: [eightDouble],
  depth: [eightDouble],
  coreTotalThickness: [eightDouble],
  holoceneThickness: [eightDouble],
  upPleiThickness: [eightDouble],
  midPleiThickness: [eightDouble],
  lowPleiThickness: [eightDouble],
  prePleiThickness: [eightDouble]
}
</script>
<style scoped></style>